package com.dst.service.impl;

import com.dst.dao.JarMapper;
import com.dst.eneity.Jar;
import com.dst.service.JarService;
import com.dst.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class JarServiceImpl implements JarService {
    @Override
    public List<Jar> selectAll() {

        List<Jar> jars;
        SqlSession sqlSession=null;
        try {
            sqlSession = MybatisUtils.getSqlSession();
            JarMapper mapper = sqlSession.getMapper(JarMapper.class);
            jars = mapper.selectAll();
        } finally {
            sqlSession.close();
        }
        return jars;
    }

    @Override
    public void insert(Jar jar) {
        List<Jar> jars;
        SqlSession sqlSession=null;
        try {
            sqlSession = MybatisUtils.getSqlSession();
            JarMapper mapper = sqlSession.getMapper(JarMapper.class);
            mapper.insert(jar);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }
}
